package com.ronghui.cash.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.ronghui.cash.entity.*;
import com.ronghui.cash.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthServiceImpl implements AuthService {

    @Autowired
    AuthProjectService authProjectService;

    @Autowired
    AuthIdentityService authIdentityService;

    @Autowired
    AuthBaiqishiService authBaiqishiService;

    @Autowired
    AuthBasicInfoService authBasicInfoService;

    @Autowired
    AuthContactService authContactService;

    @Autowired
    AuthBankService authBankService;

    @Override
    public AuthIdentity getIdentity(Long userId) {
        return authIdentityService.selectOne(new EntityWrapper<AuthIdentity>().eq("user_id", userId));
    }

    @Override
    public AuthProject getAuthProject(Long userId, String type) {
        return authProjectService.selectOne(new EntityWrapper<AuthProject>().eq("user_id", userId).eq("type", type));
    }

    @Override
    public void saveIdentity(AuthProject ap, AuthIdentity ai, AuthBaiqishi ab) {
        authProjectService.insert(ap);
        authIdentityService.insert(ai);
        authBaiqishiService.insert(ab);
    }

    @Override
    public void authBasicInfo(AuthProject ap, AuthBasicInfo abi) {
        authProjectService.insert(ap);
        authBasicInfoService.insert(abi);
    }

    @Override
    public void authContact(AuthProject ap, List<AuthContact> authContactList) {
        authProjectService.insert(ap);
        authContactService.insertBatch(authContactList);
    }

    @Override
    public void authBank(AuthBank authBank, AuthProject ap) {
        authBankService.insert(authBank);
        authProjectService.insert(ap);
    }
}
